import { MemberTypeKeyMap } from './consts';

export const getSaveValue = (
  value: { [x: string]: any; key: string; id: string },
  multiTabs: boolean,
) => {
  const [type] = value.key.split('-');
  // 单个tab只保值存id
  // 多个tab 保存 type:id
  return multiTabs ? `${MemberTypeKeyMap[type]}:${value.id}` : `${value.id}`;
};

export const getLowercase = (data: any[], tabKey?: string) => {
  return data.map((item) => {
    let _obj = {};
    for (const key in item) {
      _obj[key.toLowerCase()] = item[key];
    }
    if (tabKey) {
      _obj['key'] = `${tabKey}-${_obj?.['identityid']}`;
    }
    return _obj;
  });
};
